<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="/style/basic_layout.css" rel="stylesheet" type="text/css">
    <link href="/style/common_style.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="/js/jquery/jquery.js"></script>
    <script src="/js/plugins/artDialog/jquery.artDialog.js?skin=blue"></script>
    <script type="text/javascript" src="/js/commonAll.js"></script>
    <title>PSS-权限管理</title>
    <style>
        .alt td{ background:black !important;}
    </style>
    <script>
        $(function () {
            // 加载权限
            $(".btn_load").click(function () {
                // 1. 弹出确认框，是否需要加载权限
                $.dialog({
                    title: "提示",
                    content: "加载操作比较耗时,您确定要加载吗?",
                    icon: "face-smile",
                    ok: function () {
                        // 提前初始化提示框
                        var dialog = $.dialog({
                            title: "提示"
                        });
                        // 2. 发送 ajax 请求
                        $.post("/permission/load.do", function (data) {
                            // 显示响应回来的数据
                            dialog.content(data.msg);

                            // 3. 如果加载成功，刷新页面
                            if (data.success) {
                                // 自定义按钮
                                dialog.button({
                                    name: "确定",
                                    callback: function () {
                                        window.location.href = "/permission/list.do";
                                    }
                                });
                            } else {
                                // 出错情况不需要回调，直接增加一个按钮
                                dialog.button({name: "确定"});
                            }
                        });
                    },
                    cancel: true
                });
            });
        });
    </script>
</head>
<body>
<form id="searchForm" action="/permission/list.do" method="post">
    <div id="container">
        <div class="ui_content">
            <div class="ui_text_indent">
                <div id="box_border">
                    <div id="box_top">搜索</div>
                    <div id="box_bottom">
                        <input type="button" value="加载权限" class="ui_input_btn01 btn_load"/>
                    </div>
                </div>
            </div>
        </div>
        <div class="ui_content">
            <div class="ui_tb">
                <table class="table" cellspacing="0" cellpadding="0" width="100%" align="center" border="0">
                    <tr>
                        <th width="30"><input type="checkbox" id="all" /></th>
                        <th>ID</th>
                        <th>权限名称</th>
                        <th>权限表达式</th>
                        <th></th>
                    </tr>
                    <tbody>
                    <c:forEach items="${pageResult.list}" var="item">
                        <tr>
                            <td><input type="checkbox" name="IDCheck" class="acb" /></td>
                            <td>${item.id}</td>
                            <td>${item.name}</td>
                            <td>${item.expression}</td>
                            <td>
                                <a href="javascript:;" class="btn_delete" data-url="/permission/delete.do?id=${item.id}">删除</a>
                            </td>
                        </tr>
                    </c:forEach>
                    </tbody>
                </table>
            </div>
            <div class="ui_tb_h30">
                <%@include file="../commons/common_page.jsp"%>
            </div>
        </div>
    </div>
</form>
</body>
</html>